package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ysd.dao.impl.XiangXiXinWenDaoImpl;
import com.ysd.dao.impl.XiangXiXinWenIdDaoImpl;
import com.ysd.dao.impl.XinWenDaoimpl;
import com.ysd.entity.XiangXiXinWen;
import com.ysd.entity.XinWen;


public class NewsDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session=request.getSession();
		
		
		XiangXiXinWenIdDaoImpl xxxwIdDao=new XiangXiXinWenIdDaoImpl();//获得通过xiangXiXinWenId获取内容的实现类
		int xiangXiXinWenId=Integer.parseInt(request.getParameter("xiangXiXinWenId"));//获得前台传来的xiangXiXinWenId的值
		ArrayList<XiangXiXinWen> xxxwList=xxxwIdDao.getXiangXiXinWen(xiangXiXinWenId);//获得通过xiangXiXinWenId获取内容的实现类获取详细新闻表的数据
		session.setAttribute("xiangXiXinWenId", xiangXiXinWenId);//存数据到session
		request.setAttribute("xxxwList", xxxwList);//存数据到下个页面
		
		XiangXiXinWenDaoImpl xxxwDao=new XiangXiXinWenDaoImpl();
		ArrayList<XiangXiXinWen> xxxwXiaYiPian=xxxwDao.getXiaYiPian(xiangXiXinWenId);
		request.setAttribute("xxxwXiaYiPian", xxxwXiaYiPian);
		
		ArrayList<XiangXiXinWen> xxxwShangYiPian=xxxwDao.getShangYiPian(xiangXiXinWenId);
		request.setAttribute("xxxwShangYiPian", xxxwShangYiPian);
		
		request.getRequestDispatcher("article_list_content.jsp").forward(request, response);
		
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

	
}

